package com.thredpooldemo.config;

import org.dromara.dynamictp.spring.annotation.EnableDynamicTp;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author : hehongming
 * @createDate : 2025/4/14 11:31
 */
@EnableDynamicTp
@Configuration
@ConfigurationProperties(prefix = "dynamictp")
public class DtpConfig {
    private Integer monitorInterval;

    public Integer getMonitorInterval() {
        return monitorInterval;
    }

    public void setMonitorInterval(Integer monitorInterval) {
        this.monitorInterval = monitorInterval;
    }

    private List<ExecutorProperties> executors;  // 对应配置中的executors列表

    // Getter和Setter方法
    public List<ExecutorProperties> getExecutors() {
        return executors;
    }

    public void setExecutors(List<ExecutorProperties> executors) {
        this.executors = executors;
    }

    // 定义线程池配置的静态内部类
    public static class ExecutorProperties {
            private String threadPoolName;
            private String threadPoolAliasName;
            private String executorType;
            private int corePoolSize;
            private int maximumPoolSize;



            public String getThreadPoolName() {
                return threadPoolName;
            }

            public void setThreadPoolName(String threadPoolName) {
                this.threadPoolName = threadPoolName;
            }

            public String getThreadPoolAliasName() {
                return threadPoolAliasName;
            }

            public void setThreadPoolAliasName(String threadPoolAliasName) {
                this.threadPoolAliasName = threadPoolAliasName;
            }

            public String getExecutorType() {
                return executorType;
            }

            public void setExecutorType(String executorType) {
                this.executorType = executorType;
            }

            public int getCorePoolSize() {
                return corePoolSize;
            }

            public void setCorePoolSize(int corePoolSize) {
                this.corePoolSize = corePoolSize;
            }

            public int getMaximumPoolSize() {
                return maximumPoolSize;
            }

            public void setMaximumPoolSize(int maximumPoolSize) {
                this.maximumPoolSize = maximumPoolSize;
            }
        }
}
